package com.djl.zenithbite.controller.shopping.cart;

import com.djl.zenithbite.common.response.BaseResponse;
import com.djl.zenithbite.config.annotation.UserAuthAnnotation;
import com.djl.zenithbite.dto.request.shopping.cart.CartItemRequest;
import com.djl.zenithbite.dto.response.cart.CartResponse;
import com.djl.zenithbite.service.shopping.cart.CartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/shopping/cart")
public class CartController {

    @Autowired
    private CartService cartService;

    @UserAuthAnnotation
    @PostMapping("/list")
    public BaseResponse<List<CartResponse>> list(){
        return cartService.list();
    }


    @UserAuthAnnotation
    @GetMapping("/store")
    public BaseResponse<CartResponse> storeCart(Integer storeId){
        return cartService.storeCart(storeId);
    }

    @UserAuthAnnotation
    @PostMapping("/add")
    public BaseResponse<CartResponse> add(@RequestBody CartItemRequest request){
        return cartService.add(request);
    }

    @UserAuthAnnotation
    @PostMapping("/edit")
    public BaseResponse<CartResponse> edit(@RequestBody CartItemRequest request){
        return cartService.edit(request);
    }

}
